package com.pastquestion;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class Main11d {
	boolean[] visited;
	int ans = 0;
	public void test(String[] args) {
		int[][] edges = {{0,1},{1,2},{2,3},{1,6},{2,6},{0,5},{5,6},{4,5},{4,6},{3,4}};
		visited = new boolean[7];
		List<Integer>[] graph = buildgraph(edges);
		for (int i = 0; i < graph.length; i++) {
			dfs(graph,i);
			visited[i] = true;
		}
	}
	
	public void dfs(List<Integer>[] graph,int v) {
		if(visited[v]) return;
		for(int i : graph[v]) {
			visited[i] = true;
			dfs(graph,i);
			visited[i] = false;
		}
	}
	
	public List<Integer>[] buildgraph(int[][] edges){
		List<Integer>[] graph = new ArrayList[7];
		for (int i = 0; i < graph.length; i++) {
			graph[i] = new ArrayList<>();
		}
		
		for (int i = 0; i < edges.length; i++) {
			int from = edges[i][0],to = edges[i][1];
			graph[from].add(to);
			graph[to].add(from);
		}
		return graph;
	}

}
